home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00027_Loop Button Class.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  1.8 KB  |  79 lines

  1. property state, channel, loopLength, baseCastPos, castOffset, clicked, commandString, clickSound, ROsound
  2. global gRollAnimButton, gLoopButton
  3.  
  4. on birth me, frames, channelNum, command, soundA, soundB
  5.   set state to #idle
  6.   set loopLength to frames
  7.   set channel to channelNum
  8.   set baseCastPos to the castNum of sprite channel
  9.   set commandString to command
  10.   set castOffset to 0
  11.   set clicked to 0
  12.   set clickSound to soundA
  13.   set ROsound to soundB
  14.   puppetSprite(channel, 1)
  15.   preLoadCast(baseCastPos, baseCastPos + loopLength - 1)
  16.   return me
  17. end
  18.  
  19. on activate me
  20.   if not objectp(gRollAnimButton) then
  21.     set state to #ROsoundOn
  22.     set gLoopButton to me
  23.     puppetSound(ROsound)
  24.     changeBitmap(me)
  25.   end if
  26. end
  27.  
  28. on process me
  29.   if state = #ROsoundOn then
  30.     if not soundBusy(1) then
  31.       puppetSound(0)
  32.       if clicked = 1 then
  33.         puppetSound(clickSound)
  34.         set state to #clickSoundOn
  35.       else
  36.         set state to #ROsoundDone
  37.       end if
  38.     end if
  39.     changeBitmap(me)
  40.   else
  41.     if state = #ROsoundDone then
  42.       if clicked = 1 then
  43.         puppetSound(clickSound)
  44.         set state to #clickSoundOn
  45.       else
  46.         if rollOver(channel) then
  47.           changeBitmap(me)
  48.         else
  49.           set state to #idle
  50.           set gLoopButton to EMPTY
  51.           showAllActors()
  52.         end if
  53.       end if
  54.     else
  55.       if not soundBusy(1) then
  56.         set clicked to 0
  57.         set gLoopButton to EMPTY
  58.         do(commandString)
  59.       else
  60.         changeBitmap(me)
  61.       end if
  62.     end if
  63.   end if
  64. end
  65.  
  66. on click me
  67.   if (channel = the clickOn) and (clicked = 0) then
  68.     set clicked to 1
  69.   end if
  70. end
  71.  
  72. on changeBitmap me
  73.   set the castNum of sprite channel to baseCastPos + castOffset
  74.   set castOffset to castOffset + 1
  75.   if castOffset = loopLength then
  76.     set castOffset to 0
  77.   end if
  78. end
  79.